package com.sm.service.Impl;

import com.sm.dao.NewsDao;
import com.sm.entity.News;
import com.sm.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.DatabaseMetaData;
import java.util.Date;
import java.util.List;

@Service
public class NewsServiceImpl implements NewsService {

    @Autowired
    NewsDao newsDao;

    public List<News> findAllNews() {
//        return newsDao.findAllNews();
        return newsDao.findNewsPh();
    }

    public List<News> findNowNews(Integer limit) throws Exception {
        return newsDao.findNowNews(limit);
    }

    public News findNewsByNid(Integer nid) {
        return newsDao.findNewsByNid(nid);
    }

    public void addNews(News news) throws Exception {
        news.setDate(new Date());
        newsDao.addNews(news);
    }

    public void deleteNews(Integer nid) throws Exception {
        newsDao.deleteNews(nid);
    }
}
